package cn.cdutetc.library.entity.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 支付方式枚举
 */
@Getter
@AllArgsConstructor
public enum PayMethodEnum {

    CASH(1, "现金"),
    WECHAT(2, "微信"),
    ALIPAY(3, "支付宝"),
    BANK_CARD(4, "银行卡");

    private final Integer code;
    private final String desc;

    /**
     * 根据code获取枚举
     * @param code 状态码
     * @return 枚举
     */
    public static PayMethodEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (PayMethodEnum method : PayMethodEnum.values()) {
            if (method.getCode().equals(code)) {
                return method;
            }
        }
        return null;
    }
}